// components/dayItem/dayItem.ts
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    day:{
      type:Number
    },
    month: {
      type:Number
    },
    year: {
      type:Number
    },
    data:{
      type: Array
    },
    item: {
      type: String
    },
    navItem: {
      type:Array
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    isExpand:false as boolean,
    animationData: {},
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 去编辑页面
    toEdit(e:any): void {      
      console.log(e)
      wx.navigateTo({
        url:"/pages/editExist/editExist",
        success: (res) => {
          res.eventChannel.emit("getDetailList", {
            date:{
              year:this.data.year,
              month: this.data.month,
              today: this.data.day,
            },
            data:e.currentTarget.dataset.item
          })
        }
      })
    },
    //展开
    expand(): void {
      let animation = wx.createAnimation({
        duration: 1000,
        timingFunction: 'ease'
      });
      if(this.data.isExpand) {
        animation.height(0).scale(0.5).step();
        this.setData({
          isExpand:false,
          animationData:animation.export()
        })
      }else {
        animation.height("auto").scale(1).step();
        this.setData({
          isExpand:true,
          animationData:animation.export()
        })
      }
    } 
  }
})